<template>
	<view>
		<swiper class="carousel"
		autoplay="true"
		circular="true"
		interval="5000"
		duration="500" style="height:400rpx; ">
			<swiper-item v-for="(vo , index) in slide" class="carousel-item">
				<navigator :url="vo.url" hover-class="none">
					<image :src="vo.image" mode="widthFix" />
				</navigator>
			</swiper-item>
		</swiper>
	<!-- 	
		<view class="nav-box">
 
			<view class="nav-item" style="background-color: #5756d7;" @click="verification">
				<image src="/static/icon-1.png" mode="aspectFit"></image>
				<text>扫码验货</text>
			</view>
		</view> -->
		
		<view class="user-box">
			<image :src="user.avatar"></image>
			<view class="userinfo">
				<text class="user-nickname">{{user.user_login}}</text>
				<text class="user-mobile">{{user.user_nickname}}</text>
			</view>
		</view>
		
	</view>
</template>
<style lang="scss">
	.user-box{
		display: flex;
		flex-direction: row;
		margin: 18rpx;
		background-color: #FFFFFF;
		padding:24rpx;
		border-radius: 10rpx;
		image{
			width: 100rpx; height:100rpx; border-radius: 50%;
		}
		.userinfo{
			display: flex;
			flex-direction: column;
			margin-left: 24rpx;
			justify-content: center;
			.user-nickname{
				font-size:32rpx; color:#000000;
			}
			.user-mobile{
				font-size: 24rpx;
				margin-top: 24rpx;
				color: #666666;
			}
		}
	}
	.nav-box{
		display: flex;
		flex-direction: row;
		justify-content: center;
		margin-top:24rpx;
		.nav-item{
			margin: 0 12rpx;
			display: flex;
			flex-direction: row;
			height: 160rpx;
			flex: 1;
			border-radius: 10rpx;
			justify-content: center;
			align-items: center;
			image{
				width: 82rpx;
				height: 82rpx;
				border-radius: 50%;
				box-sizing: border-box;
				background-color: #FFFFFF;
				padding: 16rpx;
			}
			text{
				color: #FFFFFF; margin-left: 24rpx;
			}
		}
	}
</style>
<script>
	export default {
		data() {
			return {
				slide:[],
				tabcurrent:0, 
				user:{}
			}
		},
		onLoad() {
			this.$u.api.getSlide({id:1}).then(slideRes => {
				this.slide = slideRes.data[0].items;
			});
			this.$u.api.getUserInfo().then(res => {
				console.log(res)
				this.user = res.data;	
			});
			
		},
		onShow(){
			// return 
			this.$u.api.getUserInfo().then(res => {
				console.log(res)
				this.user = res.data;	
			});
		},	
		methods: {
			
			verification(e){
				this.$u.api.getUserInfo().then(res => {
					console.log(res)
					this.user = res.data;
					if(!res.data.face_image){
						uni.showModal({
							content:"请前往绑定人脸",
							showCancel:false,
							success:res => {
								uni.navigateTo({
									url:"/pages/user/face"
								})
							}
						})
					}else if(!res.data.business){
						uni.showModal({
							content:"请前往绑定营业执照",
							showCancel:false,
							success:res => {
								uni.navigateTo({
									url:"/pages/user/business"
								})
							}
						})
					}else if(!res.data.thirdPartyUser){
						uni.showModal({
							content:"请前往绑定微信",
							showCancel:false,
							success:res => {
								uni.switchTab({
									url:"/pages/my/my"
								})
							}
						})
					}else{
						uni.scanCode({
							onlyFromCamera:true,
							scanType:"qrCode",
							success:res => {
								if(res.errMsg == "scanCode:ok" && res.result){
									this.$u.http.get("mall/goods/get",{sn:res.result}).then(res => {
										if(res.code){
											uni.navigateTo({
												url:"/pages/mall/info?id="+res.data
											})
										}else{
											this.$u.toast(res.msg);
										}
									})
								}else{
									this.$u.toast("扫码失败");
								}
							},
							fail(){
								this.$u.toast("扫码失败");
							},
							complete(res){
								console.log(res);
							}
						})
					}
					
				});
				
			}
		}
	}
</script>